﻿using Abp.Domain.Entities;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.Core.Entities
{
    //交易退款账簿
    [Table("Trade_RefundBook")]
    [Serializable]
    public partial class TradeRefundBook : Entity<long>
    {
        //账本Id
        public long BookId { get; set; }

        //通道Id
        [Required]
        [StringLength(maximumLength: 20)]
        public string ChannelId { get; set; }

        //申请批号
        [Required]
        [StringLength(maximumLength: 32)]
        public string ApplyNo { get; set; }

        /// <summary>
        /// 退款交易号
        /// </summary>
        [StringLength(maximumLength: 64)]
        public string RefundTradeNo { get; set; }

        //订单号
        [StringLength(maximumLength: 32)]
        public string OrderNo { get; set; }

        /// <summary>
        /// 交易号
        /// </summary>
        [Required]
        [StringLength(maximumLength: 64)]
        public string TradeNo { get; set; }

        /// <summary>
        /// 获取申请金额
        /// </summary>
        [Range(0.01, double.MaxValue)]
        public decimal ApplyMoney { get; set; }

        //退款金额
        [Range(0.01, double.MaxValue)]
        public decimal RefundMoney { get; set; }

        //退款费用
        [Range(0.00, double.MaxValue)]
        public decimal RefundFee { get; set; }

        /// <summary>
        /// 应用Id
        /// </summary>
        [Required]
        [StringLength(maximumLength: 36)]
        public string AppId { get; set; }

        private string _AppIp;

        //应用Ip地址
        [StringLength(maximumLength: 255)]
        public string AppIp
        {
            get { return _AppIp; }
            set
            {
                if (string.IsNullOrWhiteSpace(_AppIp))
                {
                    _AppIp = "";
                }
                else
                {
                    _AppIp = value;
                }
            }
        }


        //原因
        [StringLength(maximumLength: 255)]
        public string Reason { get; set; }

        //申请时间
        public DateTime ApplyTime { get; set; }        

        //退款时间
        public DateTime RefundTime { get; set; }

        //账本时间
        public DateTime BookTime { get; set; }

        ////交易账簿
        ////[ForeignKey("Id")]
        //public virtual TradeAccountBook TradeAccountBook { get; set; }

       


    }
}
